/**
 * \class IntExp.cpp
 *
 *  Created on: 1 apr 2011
 *      Author: ytc0039
 */

#include <AbsSyn/IntExp.h>
#include <Generator/Terminals.h>
#include <Helpers/RegProvider.h>
#include <sstream>
#include <stdlib.h>
#include <RandomPkg/Randomizer.h>



IntExp::IntExp(int num):m_num(num){

	//Terminals term(Terminals::CONSTANT);
	//RegProvider<IExp* const > registry;
	//registry.RegisterClass(term.toString(),this);
	//registry.RegisterClass(this);


}

IntExp::~IntExp() {

}

void IntExp::accept(IExpVisitor *v)
{
	v->VisitIntExp(this);
}

IntExp* IntExp::clone() const {
	return (new IntExp(m_num));
}


std::string IntExp::isTerminal()
{
	return "Terminal";
}

AbsSyn::IExpPtr IntExp::generateIntExp()
{

	RandomPkg::Randomizer rndGen;
	int val = rndGen.createRandom<int>(0,10000);
	AbsSyn::IExpPtr ptr( new IntExp(val) );

	return ptr;
}

int IntExp::getInt() const
{
	return m_num;
}

void IntExp::setInt(int num)
{
	m_num = num;
}

bool IntExp::operator==( const IntExp& rhs)
{
	bool ret = false;
	if( getInt() == rhs.getInt() )
	{
		ret = true;
	}

	return ret;

}

bool IntExp::operator!=( const IntExp& rhs)
{
	return !((*this) == rhs);
}


std::string IntExp::toString() const
{
	std::ostringstream sstream;
	sstream << m_num;
	return sstream.str();
}
